import java.util.Scanner;

import com.restfb.Connection;
import com.restfb.DefaultFacebookClient;
import com.restfb.FacebookClient;
import com.restfb.FacebookClient.AccessToken;
import com.restfb.Parameter;
import com.restfb.types.Page;
import com.restfb.types.User;


public class SimpleFacebook {
	String accessToken = null;
	
	
	void login() {
		//
	}
	
	User me() {
		return null;
	}
	
	User userById() {
		return null;
	}
	
	
	public static void foo(){	
		System.out.println("Get an access token in the following address: https://developers.facebook.com/tools/explorer");
		System.out.print("Now copy the access-token here, and press ENTER: ");
		Scanner in = new Scanner(System.in);
		String accessToken = in.nextLine();
		in.close();
		
		FacebookClient facebookClient = new DefaultFacebookClient(accessToken);
		//FacebookClient facebookClient = new DefaultFacebookClient();
		
		User user = facebookClient.fetchObject("me", User.class);
		User userWithMetadata =
				  facebookClient.fetchObject("me", User.class, Parameter.with("metadata", 1));
		Page page = facebookClient.fetchObject("cocacola", Page.class);

		System.out.println("User name: " + user.getName());
		System.out.println("Page likes: " + page.getLikes());
		
		
		
		user = userWithMetadata;
		
		assert(user.getMetadata() != null);
		assert(user.getMetadata().getConnections() != null);
		assert(user.getMetadata().getConnections().getFriends() != null);
		
		System.out.println(user);
		System.out.println(user.getMetadata());
		System.out.println(user.getMetadata().getConnections());
		
		String friends = user.getMetadata().getConnections().getFriends();
		
		System.out.println("Friends: " + friends);
		
		Connection<User> myFriends = facebookClient.fetchConnection("me/friends", User.class);
		int cntr = 0;
		for (User friend : myFriends.getData()) {
			++cntr;
			System.out.println("Friend (" + cntr + "): " + friend.getName());
			//System.out.println("Friend (" + cntr + "): " + friend.getName() + "(" + friend.getBirthday() + ")");
		}
		
	}
	
	void goo() {
		AccessToken accessToken =
				  new DefaultFacebookClient().obtainAppAccessToken("MY_APP_ID", "MY_APP_SECRET");

		System.out.println("My application access token: " + accessToken);
	}

}
